﻿<UserControl x:Class="ISRecord.View.Views.ExcelImportView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
           	 xmlns:wpfExtended="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
             xmlns:p="clr-namespace:ISRecord.View.Properties"
             FlowDirection="RightToLeft" 
             mc:Ignorable="d" Loaded="ViewLoaded"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <DataTemplate x:Key="ChooseFileTemplate">
            <Grid Margin="15">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Grid.Row="0" Margin="7" VerticalAlignment="Center"
                           Text="{x:Static p:Resources.ExcelFilePath}"  />
                <TextBox Grid.Column="1" Grid.Row="0" Height="35" Margin="7,7,0,7"
                         Text="{Binding Path=ExcelFilePath, Mode=OneWay}" />
                <Button Grid.Column="2" Grid.Row="0" Content="..." Width="70" Height="35" Margin="7,7,0,7" 
                        Command="{Binding OpenExcelFileCommand}"/>
                <TextBlock Grid.Column="0" Grid.Row="1" Margin="7" VerticalAlignment="Center"
                           Text="{x:Static p:Resources.ExcelSheetName}"  />
                <TextBox Grid.Column="1" Grid.Row="1" Height="35" Margin="7,7,0,7"
                         Text="{Binding Path=ExcelSheetName, Mode=OneWay}"/>
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="AddPerfixTemplate">
            <Grid Margin="15">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Grid.Row="0" Margin="7" VerticalAlignment="Center"
                   Text="{x:Static p:Resources.BeforSubjectPrefix}"  />
                <TextBox Grid.Column="1" Grid.Row="0" Height="35" Margin="7" 
                         Text="{Binding Path=PrefixBeforSubject, UpdateSourceTrigger=LostFocus}"/>
                <TextBlock Grid.Column="0" Grid.Row="1" Margin="7" VerticalAlignment="Center"
                           Text="{x:Static p:Resources.AfterSubjectPrefix}"/>
                <TextBox Grid.Column="1" Grid.Row="1" Height="35" Margin="7" 
                         Text="{Binding Path=PrefixAfterSubject, UpdateSourceTrigger=LostFocus}"/>

            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="ResultTemplate">
            <Grid Margin="15" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Button Grid.Row="0" Command="{Binding TransportDataCommand}" Content="تحميل البيانات" Margin="7"
                        HorizontalAlignment="Right" Width="70" Height="70"/>
                <DataGrid Grid.Row="1" AutoGenerateColumns="False" Height="Auto" Margin="7" VerticalAlignment="Top" 
                          ItemsSource="{Binding Path=Outboxes}"  Name="dataGrid1"  Width="Auto" IsReadOnly="True">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="{x:Static p:Resources.OutboxNo}" Binding="{Binding Path=OutboxNo}" Width="Auto"/>
                        <DataGridTextColumn Header="{x:Static p:Resources.OutboxDate}" Binding="{Binding Path=OutboxDate}" Width="Auto"/>
                        <DataGridTextColumn Header="{x:Static p:Resources.OutboxSubject}" Binding="{Binding Path=Subject}" Width="*"/>
                        <DataGridTextColumn Header="{x:Static p:Resources.OutboxGoingTo}" Binding="{Binding Path=GoingTo}" Width="*"/>
                    </DataGrid.Columns>
                </DataGrid>
            </Grid>
        </DataTemplate>
    </UserControl.Resources>
    <Grid >
        <wpfExtended:Wizard x:Name="excelImportWizard" HelpButtonVisibility="Hidden" CancelButtonVisibility="Hidden" 
                            NextButtonContent="{x:Static p:Resources.ExcelImportView_NextButtonContent}" 
                            BackButtonContent="{x:Static p:Resources.ExcelImportView_BackButtonContent}"
                            FinishButtonContent="{x:Static p:Resources.ExcelImportView_FinishButtonContent}"
                            FinishButtonClosesWindow="False" 
                            Finish="WizardFinish" LostFocus="WizardLostFocus">

            <wpfExtended:WizardPage x:Name="IntroPage" 
                                    Title="{x:Static p:Resources.ExcelImportView_IntPage_Title}"/>

            <wpfExtended:WizardPage x:Name="ChooseFilePage"
                                    Title="{x:Static p:Resources.ExcelImportView_ChFlPage_Title}"
                                    NextPage="{Binding ElementName=PerfixPage}"
                                    PreviousPage="{Binding ElementName=IntroPage}"
                                    Content="{Binding}"
                                    ContentTemplate="{StaticResource ChooseFileTemplate}"/>

            <wpfExtended:WizardPage x:Name="PerfixPage"
                                    Title="{x:Static p:Resources.ExcelImportView_PefPage_Title}"
                                    NextPage="{Binding ElementName=ResultPage}"
                                    PreviousPage="{Binding ElementName=ChooseFilePage}"
                                    Content="{Binding}"
                                    ContentTemplate="{StaticResource AddPerfixTemplate}"/>

            <wpfExtended:WizardPage x:Name="ResultPage"
                                    Title="{x:Static p:Resources.ExcelImportView_ResPage_Title}"
                                    NextPage="{Binding ElementName=FinishPage}"
                                    PreviousPage="{Binding ElementName=PerfixPage}"
                                    Content="{Binding}"
                                    ContentTemplate="{StaticResource ResultTemplate}"
                                    CanSelectNextPage="{Binding CanSaveData}"/>

            <wpfExtended:WizardPage x:Name="FinishPage"
                                    Title="{x:Static p:Resources.ExcelImportView_FinPage_Title}"
                                    CanFinish="True"/>
        </wpfExtended:Wizard>
    </Grid>
</UserControl>
